#ifndef __BITREE_H__
#define __BITREE_H__

#include "generic.h"

#include <stddef.h>

#define BITREE_NODE(Type, ID) \
    typedef struct ID         \
    {                         \
        Type data;            \
        struct ID *left;      \
        struct ID *right;     \
    } ID;

#define BITREE_NODE_PTR(PTR, ID)        \
    ID *PTR = (ID *)malloc(sizeof(ID)); \
    PTR->left = NULL;                   \
    PTR->right = NULL;

typedef struct BitreeNode
{
    void *data;
    struct Bitree *left;
    struct Bitree *right;
} bitree_node;

typedef struct Bitree
{
    bitree_node *root;
    size_t element_size;
    generic_cons_fn cons_fn;
    generic_copy_fn copy_fn;
    generic_free_fn free_fn;
} bitree;

bitree_node *bitree_node_ptr();

bitree *bitree_ptr();

#endif